package com.kly.user.db.dao.impl;

import com.fqgj.common.base.AbstractBaseMapper;
import com.google.common.collect.Maps;
import com.kly.user.db.dao.TrafficModelPoolDao;
import com.kly.user.db.entity.TrafficModelPoolEntity;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * User: yujianfu
 * Date: 2024-01-11
 * Time: 22:09:30.563
 */

@Repository
public class TrafficModelPoolDaoImpl extends AbstractBaseMapper<TrafficModelPoolEntity> implements TrafficModelPoolDao {

    @Override
    public void refreshAllData(String activeChatTimeStart) {

        //插入新数据
        Map<String, Object> params = Maps.newHashMap();
        params.put("activeChatTimeStart", activeChatTimeStart);
        this.getSqlSession().update(this.getStatement("refreshAllData"), params);
    }

    @Override
    public void removeOldData() {
        Map<String, Object> params = Maps.newHashMap();
        params.put("maxVersion", this.getSqlSession().selectOne(this.getStatement("getMaxVersion")));
        this.getSqlSession().update(this.getStatement("removeOldData"), params);
    }

    @Override
    public void updateOnlineStatus() {
        this.getSqlSession().update(this.getStatement("updateOnlineStatus"));
    }

//    @Override
//    public void updateActiveChats(String activeChatTimeStart, Integer type) {
//        Map<String, Object> params = Maps.newHashMap();
//        params.put("activeChatTimeStart", activeChatTimeStart);
//        if (type == 1)
//            this.getSqlSession().update(this.getStatement("updateActiveChatsModel"), params);
//        else
//            this.getSqlSession().update(this.getStatement("updateActiveChatsChatter"), params);
//    }

    @Override
    public List<TrafficModelPoolEntity> queryTrafficHPIssueUsers(String userCode, int limitNum) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("userCode", userCode);
        params.put("limitNum", limitNum);
        return this.getSqlSession().selectList(this.getStatement("queryTrafficHPIssueUsers"), params);
    }
}